package com.web.netty.domain;

import java.io.Serializable;
import java.util.Arrays;

/**
 * @Author: wws
 * describe:
 */
public class ReJoinData implements Serializable {

    private byte head;
    private byte[] token;
    private byte direction;
    private byte[] deviceEui;
    private byte[] gatewayEui;
    private ReJoinPayload PayLoad;

    public ReJoinData() {
    }

    public ReJoinData(byte[] data) {
        this.head = data[0];
        this.token = Arrays.copyOfRange(data, 1, 3);
        this.direction =  data[3];
        this.deviceEui =  Arrays.copyOfRange(data, 4, 12);
        this.gatewayEui =  Arrays.copyOfRange(data, 12, 20);
        this.PayLoad = new ReJoinPayload(Arrays.copyOfRange(data, 20, data.length));
    }

    public ReJoinData(byte head, byte[] token, byte direction, byte[] deviceEui, byte[] gatewayEui, ReJoinPayload payLoad) {
        this.head = head;
        this.token = token;
        this.direction = direction;
        this.deviceEui = deviceEui;
        this.gatewayEui = gatewayEui;
        PayLoad = payLoad;
    }

    public byte getHead() {
        return head;
    }

    public void setHead(byte head) {
        this.head = head;
    }

    public byte[] getToken() {
        return token;
    }

    public void setToken(byte[] token) {
        this.token = token;
    }

    public byte getDirection() {
        return direction;
    }

    public void setDirection(byte direction) {
        this.direction = direction;
    }

    public byte[] getDeviceEui() {
        return deviceEui;
    }

    public void setDeviceEui(byte[] deviceEui) {
        this.deviceEui = deviceEui;
    }

    public byte[] getGatewayEui() {
        return gatewayEui;
    }

    public void setGatewayEui(byte[] gatewayEui) {
        this.gatewayEui = gatewayEui;
    }

    public ReJoinPayload getPayLoad() {
        return PayLoad;
    }

    public void setPayLoad(ReJoinPayload payLoad) {
        PayLoad = payLoad;
    }

    @Override
    public String toString() {
        return "ReJoinData{" +
                "head=" + head +
                ", token=" + Arrays.toString(token) +
                ", direction=" + direction +
                ", deviceEui=" + Arrays.toString(deviceEui) +
                ", gatewayEui=" + Arrays.toString(gatewayEui) +
                ", PayLoad=" + PayLoad +
                '}';
    }
}
